/*
 * Copyright (c) 2017,重庆阿莫比科技有限公司,All Rights Reserved.
 */
package com.wowocai.btchina.filter;

import java.io.IOException;
import java.util.zip.GZIPInputStream;

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;

public class GzipRequestStream extends ServletInputStream {

    private GZIPInputStream in;

    public GzipRequestStream(HttpServletRequest request) throws IOException {
        this.in = new GZIPInputStream(request.getInputStream());
    }

    @Override
    public int read() throws IOException {
        return in.read();
    }

    @Override
    public int read(byte[] b) throws IOException {
        return in.read(b);
    }

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        return in.read(b, off, len);
    }

    @Override
    public void close() throws IOException {
        in.close();
    }

    /**
     * TODO The function of this method is described here - Optional.
     * 
     * @see javax.servlet.ServletInputStream#isFinished()
     */
    @Override
    public boolean isFinished() {

        return false;
    }

    /**
     * TODO The function of this method is described here - Optional.
     * 
     * @see javax.servlet.ServletInputStream#isReady()
     */
    @Override
    public boolean isReady() {

        return false;
    }

    /**
     * TODO The function of this method is described here - Optional.
     * 
     * @see javax.servlet.ServletInputStream#setReadListener(javax.servlet.ReadListener)
     */
    @Override
    public void setReadListener(ReadListener readListener) {

        // TODO Auto-generated method stub

    }
}
